﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>Upload</title>
    <link href="/css/fineuploader.css" rel="stylesheet" />
    <link href="/css/bootstrap.min.css" rel="stylesheet" />
    <link href="/css/bootstrap-responsive.min.css" rel="stylesheet" />

    <link href="/css/base.css" rel="stylesheet"/>
        
    <link href="/css/upload.css" rel="stylesheet" />    
    <script src="/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="/scripts/textarea.js" type="text/javascript"></script>
    <script src="/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/scripts/jquery.fineuploader-3.1.min.js" type="text/javascript"></script>
</head>
<body>
<div id="jquery-wrapped-fine-uploader"></div>
<div id="message"></div>
<script type="text/javascript">
    var ajaxUrl = '/home/ProcessUpload';
    $(function () {
        $('#jquery-wrapped-fine-uploader').fineUploader({
            validation: {
                allowedExtensions: ['png', 'gif', 'jpg', 'jpeg'],
                sizeLimit: 10 * 1024 * 1024
            },
            request: {
                endpoint: ajaxUrl
            },
            text: {
                uploadButton: '<i class="icon-upload icon-white"></i> 上传本地图片',
                dropProcessing: '（支持文件拖放上传）'
            },
            showMessage: function (message) {
                $('#message').html(message);
            },
            template:
                '<div class="qq-uploader span12">' +
                '<pre class="qq-upload-drop-area span12"><span>{dragZoneText}</span></pre>' +
                '<div class="qq-upload-button btn btn-success" style="width: auto;">{uploadButtonText}</div>' +
                '<span class="qq-drop-processing"><span>{dropProcessingText}</span><span class="qq-drop-processing-spinner"></span></span>' +
                '<ul class="qq-upload-list" style="margin-top: 10px;overflow:hidden;"><div style="margin-top: 10px;">只能上传单张10M以下的 png、jpg、gif 格式的图片</div></ul>' +
                '</div>',
            classes: {
                success: 'alert alert-success',
                fail: 'alert alert-error'
            },
            multiple: false
        }).on('complete', function (event, id, fileName, responseJSON) {
            if (responseJSON.success) {
                document.domain = 'cnblogs.' + location.hostname.substring(location.hostname.lastIndexOf(".") + 1, location.hostname.length);
                parseText(location.hash.substring(1), '[img]' + responseJSON.message + '[/img]\n');
                window.close();
            }
            else {
                $('#message').html(responseJSON.message);
            }
        });
    });
</script>

</body>
</html>
